home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2009 December / maximum-cd-2009-12.iso / DiscContents / gimp-2.7.0-i686-setup.exe / {app} / share / gimp / 2.0 / scripts / predator.scm < prev    next >
Encoding:
GIMP Script-Fu Script  |  2009-08-19  |  4.6 KB  |  135 lines

  1. ; GIMP - The GNU Image Manipulation Program
  2. ; Copyright (C) 1995 Spencer Kimball and Peter Mattis
  3. ;
  4. ; Predator effect
  5. ; Copyright (c) 1997 Adrian Likins
  6. ; aklikins@eos.ncsu.ed
  7. ;
  8. ;  The idea here is too make the image/selection look sort of like
  9. ;  the view the predator had in the movies. ie, kind of a thermogram
  10. ;  type of thing. Works best on colorful rgb images.
  11. ;
  12. ; This program is free software: you can redistribute it and/or modify
  13. ; it under the terms of the GNU General Public License as published by
  14. ; the Free Software Foundation; either version 3 of the License, or
  15. ; (at your option) any later version.
  16. ;
  17. ; This program is distributed in the hope that it will be useful,
  18. ; but WITHOUT ANY WARRANTY; without even the implied warranty of
  19. ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  20. ; GNU General Public License for more details.
  21. ;
  22. ; You should have received a copy of the GNU General Public License
  23. ; along with this program.  If not, see <http://www.gnu.org/licenses/>.
  24.  
  25.  
  26. (define (script-fu-predator image
  27.                             drawable
  28.                             edge-amount
  29.                             pixelize
  30.                             pixel-size
  31.                             keep-selection
  32.                             separate-layer)
  33.   (let* (
  34.         (type (car (gimp-drawable-type-with-alpha drawable)))
  35.         (image-width (car (gimp-image-width image)))
  36.         (image-height (car (gimp-image-height image)))
  37.         (active-selection 0)
  38.         (from-selection 0)
  39.         (selection-bounds 0)
  40.         (select-offset-x 0)
  41.         (select-offset-y 0)
  42.         (select-width 0)
  43.         (select-height 0)
  44.         (effect-layer 0)
  45.         (active-layer 0)
  46.         )
  47.  
  48.     (gimp-image-undo-group-start image)
  49.     (gimp-layer-add-alpha drawable)
  50.  
  51.     (if (= (car (gimp-selection-is-empty image)) TRUE)
  52.         (begin
  53.           (gimp-selection-layer-alpha drawable)
  54.           (set! active-selection (car (gimp-selection-save image)))
  55.           (set! from-selection FALSE)
  56.         )
  57.         (begin
  58.           (set! from-selection TRUE)
  59.           (set! active-selection (car (gimp-selection-save image)))
  60.         )
  61.     )
  62.  
  63.     (set! selection-bounds (gimp-selection-bounds image))
  64.     (set! select-offset-x (cadr selection-bounds))
  65.     (set! select-offset-y (caddr selection-bounds))
  66.     (set! select-width (- (cadr (cddr selection-bounds)) select-offset-x))
  67.     (set! select-height (- (caddr (cddr selection-bounds)) select-offset-y))
  68.  
  69.     (if (= separate-layer TRUE)
  70.         (begin
  71.           (set! effect-layer (car (gimp-layer-new image
  72.                                                   select-width
  73.                                                   select-height
  74.                                                   type
  75.                                                   "glow layer"
  76.                                                   100
  77.                                                   NORMAL-MODE))
  78.           )
  79.  
  80.           (gimp-layer-set-offsets effect-layer select-offset-x select-offset-y)
  81.           (gimp-image-add-layer image effect-layer -1)
  82.           (gimp-selection-none image)
  83.           (gimp-edit-clear effect-layer)
  84.  
  85.           (gimp-selection-load active-selection)
  86.           (gimp-edit-copy drawable)
  87.           (let ((floating-sel (car (gimp-edit-paste effect-layer FALSE))))
  88.             (gimp-floating-sel-anchor floating-sel)
  89.           )
  90.           (gimp-image-set-active-layer image effect-layer)
  91.         )
  92.         (set! effect-layer drawable)
  93.     )
  94.     (set! active-layer effect-layer)
  95.  
  96.     ; all the fun stuff goes here
  97.     (if (= pixelize TRUE)
  98.         (plug-in-pixelize RUN-NONINTERACTIVE image active-layer pixel-size)
  99.     )
  100.     (plug-in-max-rgb RUN-NONINTERACTIVE image active-layer 0)
  101.     (plug-in-edge RUN-NONINTERACTIVE image active-layer edge-amount 1 0)
  102.  
  103.     ; clean up the selection copy
  104.     (gimp-selection-load active-selection)
  105.  
  106.     (if (= keep-selection FALSE)
  107.         (gimp-selection-none image)
  108.     )
  109.  
  110.     (gimp-image-set-active-layer image drawable)
  111.     (gimp-image-remove-channel image active-selection)
  112.     (gimp-image-undo-group-end image)
  113.     (gimp-displays-flush)
  114.   )
  115. )
  116.  
  117. (script-fu-register "script-fu-predator"
  118.   _"_Predator..."
  119.   _"Add a 'Predator' effect to the selected region (or alpha)"
  120.   "Adrian Likins <adrian@gimp.org>"
  121.   "Adrian Likins"
  122.   "10/12/97"
  123.   "RGB*"
  124.   SF-IMAGE       "Image"          0
  125.   SF-DRAWABLE    "Drawable"       0
  126.   SF-ADJUSTMENT _"Edge amount"    '(2 0 24 1 1 0 0)
  127.   SF-TOGGLE     _"Pixelize"       TRUE
  128.   SF-ADJUSTMENT _"Pixel amount"   '(3 1 16 1 1 0 0)
  129.   SF-TOGGLE     _"Keep selection" TRUE
  130.   SF-TOGGLE     _"Separate layer" TRUE
  131. )
  132.  
  133. (script-fu-menu-register "script-fu-predator"
  134.                          "<Image>/Filters/Artistic")
  135.